<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue-2.4.0.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-model.number="age" v-color="color">
    <input type="text" v-model.trim="info" v-focus>
    <input type="text" v-model.lazy="msg" v-col="color">
    <button @click="handle">点击</button>
    {{age}}
    {{msg}}
</div>
<script>
    // 自定义属性
    Vue.directive('focus',{
        inserted(el){
            el.focus()
        }
    })
    Vue.directive('color',{
        bind:function (el,binding) {
            console.log(binding)
            el.style.background=binding.value
        }
    })
    var vm=new Vue({
        el:'#app',
        data:{
            age:'',
            info:'',
            msg:'hello',
            color:'orange'
        },
        methods:{
            handle:function () {
                this.age+=13
                console.log(this.info)
            }
        },
        directives:{
            col(el,binding) {
                    console.log(binding)
                    el.style.background=binding.value
                }

        }
    })
</script>
</body>
</html>